#ifndef __TASK_H_
#define __TASK_H_

#include <iostream>
#include <pthread.h>
#include "util.h"

class Task {
 public:
  unsigned int id;  /*ID given for each task */
  unsigned int priority; /* a user assigned priority to the task in question */
  bool done;
  pthread_mutex_t dmutex;
  pthread_cond_t tdone;
  TState* myState; /* pointer to a state enum, can be used to manage children or to declare my state */
  TState* doneState; /* state to depict end for deleting */


  Task() { /* default constructor */
    id = 0; 
    done = false;
    doneState = new TState();
    *doneState = Create;
  }
  
  Task(unsigned int i) {/* constructor */
    id = i;
    done = false;
  }

  virtual ~Task(){
    *doneState = Create;
  }

  virtual void run () {}; // virtual function that the user must override //

  virtual void doneWithTask() {
       delete this;
   }

  virtual void print() {// printing function for testing purposes //
  }

};

#endif 
